using System.Collections.Generic;
using DataAccess.Services.Interfaces;
using DataControl;
using NHibernate;

namespace DataAccess.Services.Gateways
{
	internal class AccountGateway : GatewayBase<Account>, IAccountGateway
	{
		public AccountGateway(ISession session) : base(session)
		{
		}

		public bool Exists(string accountCode)
		{
			return DataControl.IsAccountExist(accountCode);
		}

		public Account GetAccountByNumber(string accountCode)
		{
			return DataControl.GetAccountByNumber(accountCode);
		}

		public void UpdateBalance(int accountId, decimal balance)
		{
			DataControl.UpdateBalance(accountId, balance);
		}

		public IEnumerable<Account> GetClientAccount(int clientId)
		{
			return DataControl.GetFiltredItems<Account>("AccounteeFK", clientId);
		}

		public IList<Account> GetAllAccounts()
		{
			return DataControl.GetAllItems<Account>();
		}
	}
}